Strict

Import mojo
Import agfx

Class TEventTimer


	Private
	Field _start_time:Int
	Field enable:Bool
	Field time:Int
	

	Public	
	Field Callback:TCallback
	
	Method New()
		Self.enable = False	
		Self.Callback = New TCallback()
	End Method


	Method Update:Void()
		If Self.enable Then
			If Millisecs()>(Self.time+Self._start_time) Then 
				Self.Callback.Call()
				Self._start_time = Millisecs()
			End If
		End IF		
	End Method

	Method Enable:Void()
		Self.enable = True
		Self._start_time = Millisecs()
	End Method

	Method Disable:Void()
		Self.enable = False		
	End Method

	Method SetTime:Void(t:Int)
		Self.time = t
	End Method

	Method GetTime:Int()
		return Self.time
	End Method

End Class